<?php
/**
 * Product components
 *
 * No redirection nor database manipulation ( insert, update, delete ) here
 *
 *
 *
 *
 */
class productComponents extends myFrontModuleComponents {

    public function executeList() {
        $query = $this->getListQuery();

        $this->productPager = $this->getPager($query);
    }

    public function executeListByProductCategory() {
        $query = $this->getListQuery();

        $this->productPager = $this->getPager($query);
    }

    public function executeShow() {
        $query = $this->getShowQuery('p')
                ->leftJoin('p.ProductDetailFields pdf')
                ->leftJoin('p.ProductSizeList pds')
                ->orderBy('pdf.name')
                ->orderBy('pds.position');

        $this->product = $this->getRecord($query);
    }

    public function executeListbyslide() {
        $query = $this->getListQuery();

        $this->productPager = $this->getPager($query);
    }

    public function executeListbynew() {
        $query = $this->getListQuery();

        $this->productPager = $this->getPager($query);
    }

    public function executeListbyinner() {
        $query = $this->getListQuery('p')
                ->addWhere('p.body_length =?', '');

        $this->productPager = $this->getPager($query);
    }
    public function executeListbygetonefree() {
        $query = $this->getListQuery('p')
                ->addWhere('p.body_length =?', 'BUY 1 GET 1 FREE');

        $this->productPager = $this->getPager($query);
    }
    public function executeListbydiscount() {
        $query = $this->getListQuery('p')
                ->addWhere('p.body_length =?', 'DISCOUNTED PRODUCTS');

        $this->productPager = $this->getPager($query);
    }

    public function executeListbygetfree() {
        $query = $this->getListQuery('p')
                ->addWhere('p.body_length =?', 'FREEEEEE');

        $this->productPager = $this->getPager($query);
    }

    public function executeListbycommingsoon() {
        $query = $this->getListQuery('p')
                ->addWhere('p.body_length =?', 'COMING SOON');

        $this->productPager = $this->getPager($query);
    }

    public function executeListbystudent() {
        $query = $this->getListQuery('p')
                ->addWhere('p.body_length =?', "STUDENTS OFFER");

        $this->productPager = $this->getPager($query);
    }


}
